package ph.com.isla.sf2d.ui;

import ph.com.isla.sf2d.SF2DSurfaceView;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;

public class SF2DImageButton extends SF2DButton {
	private Bitmap mNormalBitmap;
	private Bitmap mFocusBitmap;
	private Bitmap mPressedBitmap;
	private Paint mBitmapPaint = null;

	public SF2DImageButton(SF2DSurfaceView root) {
		super(root);
		mBitmapPaint = new Paint();
		mBitmapPaint.setAntiAlias(true);
	}

	public void setBitmap(Bitmap normal, Bitmap focus, Bitmap pressed) {
		mNormalBitmap = normal;
		mFocusBitmap = focus;
		mPressedBitmap = pressed;
	}

	@Override
	public void draw(Canvas canvas) {
		Bitmap bitmap = null;
		if (getState() == NORMAL) {
			bitmap = mNormalBitmap;
		} else if (getState() == FOCUSED) {
			bitmap = mFocusBitmap;
		} else if (getState() == PRESSED) {
			bitmap = mPressedBitmap;
		}
		
		if (bitmap != null)
			canvas.drawBitmap(bitmap, 0, 0, mBitmapPaint);

	}

}
